import axios from "@/utils/axios";

export default {
  // 模糊查询学生
  searchStudents(key) {
    return axios.get('/students/search', {params: {key}})
  },
  // 模糊查询机构员工
  searchStaff(search) {
    return axios.get('/users/staffs/search', {params: {searchStaff: true, search, include: 'site_admin'}})
  },
  // 查询幼儿园或班级
  listCentersOrGroups() {
    return axios.get('/schools/all/schoolsOrGroups')
  },
  // 查询幼儿园相关人员
  listCenterUsers(schoolId) {
    return axios.get('/messages/school/user', {params: {schoolId}})
  },
  // 查询班级学生
  listGroupStudents(groupId) {
    return axios.get('/messages/group/student', {params: {groupId}});
  },
  // 获取消息记录
  getMessages(params) {
    return axios.post("/messages/getMessageStats", params)
  },
  // 获取单条用户消息统计已读未读信息
  getSingleMessageStats(messageId) {
    return axios.get("/messages/getSingleMessageStats", {params: {messageId}})
  },
  /* 发送消息：receiveRole, subject, content, sendType, sendAtLocal, staffCenterIds, staffGroupIds, staffIds,
   childCenterIds, childGroupIds, childIds, attachments*/
  sendMessage(message) {
    return axios.post('/messages', message)
  },
  // 生成 PDF
  generatePDF(messageId) {
    return axios.get('/messages/generateSingleMessageStatsPdf', {params: {messageId}});
  },
  // 预发送消息
  preSendMessage (message) {
    return axios.post('/messages/preSendMessage', message)
  },
  // 撤回消息发送
  undoSendMessage (messageId) {
    return axios.get('/messages/undoSendMessage', { params: { messageId } })
  },
  // 获取单条消息
  getMessage (messageId) {
    return axios.get('/messages/getMessage', { params: { messageId } })
  }
}
